package org.third.common.datasource;

import java.util.Map;
import javax.sql.DataSource;
import org.hibernate.engine.jdbc.connections.spi.AbstractDataSourceBasedMultiTenantConnectionProviderImpl;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * Created by Huailong Tang(Jason) on 2017/10/16.
 */
public class DataSourceBasedMultiTenantConnectionProviderImpl extends
    AbstractDataSourceBasedMultiTenantConnectionProviderImpl {

  @Autowired
  private Map<String,DataSource> installerDataSource;

  @Override
  protected DataSource selectAnyDataSource() {
    return this.installerDataSource.get("DEFAULT");
  }

  @Override
  protected DataSource selectDataSource(String tenantId) {
    return this.installerDataSource.get(tenantId);
  }
}
